package com.example.springbook.service;

import com.example.springbook.bean.Borrow;
import com.example.springbook.bean.User;
import com.example.springbook.dao.BorrowDao;
import com.example.springbook.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BorrowServicelmpl implements BorrowService{
    @Autowired
    private BorrowDao borrowDao;

    @Override
    public boolean addBorrow(Borrow borrow){
        boolean flag=false;
        try{ borrowDao.addBorrow(borrow); flag=true;}catch (Exception e){e.printStackTrace();}
        return flag;
    }

    @Override
    public boolean updateBorrow(int id) {
        boolean flag=false;
        try{ borrowDao.updateBorrow(id); flag=true;}catch (Exception e){e.printStackTrace();}
        return flag;
    }

    @Override
    public boolean deleteBorrow(int id) {
        boolean flag=false;
        try{ borrowDao.deleteBorrow(id); flag=true;}catch (Exception e){e.printStackTrace();}
        return flag;
    }

    @Override
    public List<Borrow> findAllBorrow() {
        return borrowDao.findAllBorrow();
    }

    @Override
    public List<Borrow> findBorrowByBook(int bookid) {
        return borrowDao.findBorrowByBook(bookid);
    }

    @Override
    public List<Borrow> findBorrowByUser(int userid) {
        return borrowDao.findBorrowByUser(userid);
    }
}
